#include "grass.h"

CGrass::CGrass()
{

}

CGrass::~CGrass()
{

}

CGrass::CGrass(int Type, float X, float Y)
{
	reality = 0;
	type = Type;
	pos_x = X;
	pos_y = Y;
}

void CGrass::RenderPieceGrass(int P,float x,float y)
{
	if(P == 1)
		StaticPic->Render(_BackBuffer,x,y,0,2);
	else if(P == 2)
		StaticPic->Render(_BackBuffer,x,y,0,3);
	else if(P == 3)
		StaticPic->Render(_BackBuffer,x,y,0,4);
}

void CGrass::RenderFrame(LPDIRECT3DDEVICE9 d3ddv, int t)
{
	SpriteHandlerSP->Begin(D3DXSPRITE_ALPHABLEND);
	if(type == 1)	
	{
		RenderPieceGrass(1,pos_x,		pos_y);
		RenderPieceGrass(2,pos_x+DIS,	pos_y);
		RenderPieceGrass(3,pos_x+2*DIS,	pos_y);
	}
	else if(type == 0)
	{
		RenderPieceGrass(1,pos_x,		pos_y);
		RenderPieceGrass(3,pos_x+DIS,	pos_y);
	}
	else if(type == 2)
	{
		RenderPieceGrass(1,pos_x,		pos_y);
		RenderPieceGrass(2,pos_x+DIS,	pos_y);
		RenderPieceGrass(2,pos_x+2*DIS,	pos_y);
		RenderPieceGrass(3,pos_x+3*DIS,	pos_y);
	}
	SpriteHandlerSP->End();
}